import React, { Component } from 'react';
import {Layout, Button, Tooltip ,Select,Input,Row, Col,Table, Switch, Space} from 'antd';
import '../App.css';
import { CopyOutlined ,SearchOutlined,
    AlignLeftOutlined,AlignCenterOutlined,AlignRightOutlined,
    InsertRowAboveOutlined,InsertRowBelowOutlined,
    InsertRowLeftOutlined,InsertRowRightOutlined,
    DeleteRowOutlined ,DeleteColumnOutlined,
    FileAddOutlined,BoldOutlined ,ItalicOutlined,UnderlineOutlined,
    TableOutlined,BorderTopOutlined,BorderRightOutlined,BorderBottomOutlined,BorderLeftOutlined,
    SmallDashOutlined,BorderOutlined,DragOutlined,SaveOutlined,RollbackOutlined,FundViewOutlined,
} from '@ant-design/icons';


import '../pages/webExcel.css'
import {getForms} from "../api/formManagement";
const { Header, Content, Footer } = Layout;
const { Option } = Select;

export default class FormList extends Component {
    constructor(props) {
        super(props)
        this.state = {
            forms:[]
        }
    }

    componentWillReceiveProps(nextProps){
        let foldId=nextProps.formFolderId;
        //查询后端  把后端数据组织到前端
        getForms(foldId).then(
            (res) => {
                this.setState({forms: res.data});
            },
            (error) => {
                console.log("get response failed!");
            }
        );

    }







    render() {
        const columns = [
            {
                title: '表单名称',
                dataIndex: 'name',
                key: 'id',
            }]



        const rowSelection2 = {
            onChange: (selectedRowKeys, selectedRows) => {
                //  console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
            },
            onSelect: (record, selected, selectedRows) => {

                if(selected){
                     this.props.selectForm (record.id);
                }else{
                  //todo
                }
            },

        };

        return (
                    <>
                        <Table columns={columns}
                               dataSource={this.state.forms}
                               rowSelection={{
                                   type: 'radio',
                                   ...rowSelection2,
                               }}
                                //rowSelection={{ ...rowSelection2,checkStrictly:true}}
                        />
                    </>
                )
    }

}
